package cn.facetoken.homer;

import androidx.fragment.app.Fragment;

enum Demonstration {
    // FACE_DETECTION,
    FACE_REGISTRATION, FACE_RECOGNITION, EYEPRINT_RECOGNITION, GENDER_CLASSIFICATION, AGE_ESTIMATION;

    public static final String ARGUMENT_DEMONSTRATION_ID = "demonstration_id";

    public int getTitleResourceId() {
        switch(this) {
            case FACE_RECOGNITION:
                return R.string.demonstration_face_recognition_title;
            case EYEPRINT_RECOGNITION:
                return R.string.demonstration_eyeprint_recognition_title;
            case GENDER_CLASSIFICATION:
                return R.string.demonstration_gender_classification_title;
            case AGE_ESTIMATION:
                return R.string.demonstration_age_estimation_title;
            default: // FACE_REGISTRATION
                return R.string.demonstration_face_registration_title;
        }
    }

    public int getDescriptionResourceId() {
        switch(this) {
            case FACE_RECOGNITION:
                return R.string.demonstration_face_recognition_description;
            case EYEPRINT_RECOGNITION:
                return R.string.demonstration_eyeprint_recognition_description;
            case GENDER_CLASSIFICATION:
                return R.string.demonstration_gender_classification_description;
            case AGE_ESTIMATION:
                return R.string.demonstration_age_estimation_description;
            default: // FACE_REGISTRATION
                return R.string.demonstration_face_registration_description;
        }
    }

    public Class<? extends Fragment> getFragmentClass() {
        switch(this) {
            case FACE_RECOGNITION:
                return FaceRecognitionFragment.class;
            case EYEPRINT_RECOGNITION:
                return EyeprintRecognitionFragment.class;
            case GENDER_CLASSIFICATION:
                return GenderClassificationFragment.class;
            case AGE_ESTIMATION:
                return AgeEstimationFragment.class;
            default: // FACE_REGISTRATION
                return FaceRegistrationListFragment.class;
        }
    }

    public boolean isActive() {
        switch(this) {
            case FACE_RECOGNITION:
            case EYEPRINT_RECOGNITION:
                return true;
            case GENDER_CLASSIFICATION:
            case AGE_ESTIMATION:
                return false;
            default: // FACE_REGISTRATION
                return true;
        }
    }

    public Fragment newFragment() {
        try {
            return getFragmentClass().newInstance();
        } catch (IllegalAccessException | InstantiationException e) {
            throw new RuntimeException(e);
        }
    }
}
